<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
.note-editor .note-editable{
	min-height: 200px!important;
}
</style>
</head>
<body class="gray-bg">
	<form class="form-horizontal" id="commentForm">
		<div class="business-padding">
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table" style="width: 100%;">
				<tr>
					<td><input id="titleInbox" maxlength="20" name="titleInbox" type="text" class="form-control" required="required"
						aria-required="true" placeholder="邮件标题(必填)"></td>
				</tr>
			</table>
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table" style="width: 30%;">
				<tr>
					<td>
						<input id="dateInbox" name="dateInbox" type="text" class="laydate-icon form-control" required="" aria-required="true" placeholder="邮件有效期(必填)">
					</td>
				</tr>
			</table>
		</div>
		
		<div class="business-padding">
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table" style="width: 100%;">
				<tr>
					<td>
						<textarea id="contentInbox" name="contentInbox" type="text"  class="form-control" placeholder="请输入邮件内容"></textarea>
					</td>
				</tr>
			</table>
		</div>
		
		<table cellpadding="0" cellspacing="0" border="0" bordercolor="#3B95C8" width="100%">
			<tr>
				<td width="100%" align="center">
					<div class="ibox-content">
						<button type="button" class="btn dpbtn_green" onclick="save();">确定</button>
						<button type="reset" class="btn dpbtn_red" onclick="$('#contentInbox').code('');">重置</button>
					</div>
				</td>
			</tr>
		</table>
	</form>

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- custom js -->
	<%@include file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<script type="text/javascript" src="${basePath}/js/commonvalidate.js" charset="utf-8"></script>
	<!-- layerDate plugin javascript -->
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
	<!-- summernote -->
	<%@include file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>

	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
    jQuery(function($) { 
    	var start = {
  			  elem: '#dateInbox', 
		      event: 'focus' ,
  			  format: 'YYYY-MM-DD',
  			  max: '2099-06-16', //最大日期
  			  istime: true,
  			  istoday: false
  			};
    	laydate(start);
    	 $('#contentInbox').summernote({
	            lang: 'zh-CN',
	            toolbar:[
					['style', ['bold', 'italic', 'underline', 'clear']],
					['color', ['color']]
	            ]
	        });
    	 getData();
    });
    function getData(){
    	var id = $.getUrlData('id');
    	if(!id || id == '') {
    		return;
    	}
	    $.dpAjax({
      		show:true,
	    	url:'${basePath}/OtherNoticeController/getById',
   			data:{id: id},
   			success: function(datas){
    			  if(datas.flag == "100100"){
    				 var otherNotice = datas.result;
    				 //征信信息
    				 if(otherNotice) {
     					$('#id').val(otherNotice.id);
     					$('#titleInbox').val(otherNotice.titleInbox);
     					$('#dateInbox').val(formateStringDate(otherNotice.dateInbox));
     					$('#contentInbox').code(otherNotice.contentInbox);
    				 }
				  }
   			}
	    });
    }
	var save = function(){
		var titleInbox = $("#titleInbox").val();
   		var contentInbox = $("#contentInbox").code();
   		var dateInbox = $("#dateInbox").val();
   		
   		if(titleInbox==''){
			layer.msg("请输入邮件标题", {icon: 5});
			return;
		}
   		if(dateInbox==''){
			layer.msg("请输入邮件有效时间", {icon: 5});
			return;
		}
   		if(contentInbox==''){
			layer.msg("请输入邮件内容", {icon: 5});
			return;
		}
   		var data = {};
    	var id = $.getUrlData('id');
    	var url = '';
    	if(id && id != '') {
   			data.id=id;
    		url = '${basePath}/OtherNoticeController/modify';
    	} else {
    		url = '${basePath}/OtherNoticeController/save';
    	}
   		data.titleInbox = $('#titleInbox').val();
   		data.dateInbox = $('#dateInbox').val();
   		data.contentInbox = $('#contentInbox').code();
		$.dpAjax({
    		url:url,
   			data:data,
   			success: function(datas){
    			  if(datas.flag == "100100")
				  {
   				 	  layer.msg("执行成功！", {icon: 6});
   				 	  parent.layer.close(parent.addlayer);
				  return;
				  }
				  if(datas.flag == "100200")
                  {
					  $.fn.showDatas({"datas":datas});
                	  return;
                  }
				  layer.msg(datas.message, {icon: 2});
               }
    	});
	}
	
	 function formateStringDate(sDate1){
	    	if(!sDate1 || sDate1 == ''){
	    		return '';
	    	}
	    	var aDate  =  sDate1.split(" ");
	    	return aDate[0];
	    }
   </script>
</body>
</html>
